<template>
  <section class="chart-container">
    <div class="c_checkbox">
      <div style="width:15%">
        <div style="margin: 20px 0;">责任单位 :</div>
        <el-checkbox-group v-model="checkedqtdw">
          <el-checkbox v-for="item in qtdw" :label="item.hash.orgid" :key="item.hash.id">{{item.hash.orgname}}</el-checkbox>
        </el-checkbox-group>
      </div>
      <div style="line-height:3.6">
        <i class="el-icon-d-arrow-right" style="font-size:18px"></i><i class="el-icon-d-arrow-right" style="font-size:18px"></i><i class="el-icon-d-arrow-right" style="font-size:18px"></i>
      </div>
      <div style="width:15%">
        <div style="margin: 20px 0;">协同单位 :</div>
        <el-checkbox-group v-model="checkedzrdw">
          <el-checkbox v-for="item in zrdw" :label="item.hash.orgid" :key="item.hash.id">{{item.hash.orgname}}</el-checkbox>
        </el-checkbox-group>
      </div>

      <div style="margin-top:20px">
        <el-button type="primary" @click="sumitobj">提 交</el-button>
      </div>

    </div>

  </section>
</template>

<script>
const cityOptions = ['上海', '北京', '广州', '深圳'];
export default {
  data() {
    return {
      ts: this.newStore(),
      qtdw: [],
      zrdw: [],
      checkedCities: ['上海', '北京'],
      checkedqtdw: [],
      checkedzrdw: [],
      cities: cityOptions,
      isIndeterminate: true,
    };
  },
  created() {
    this.getobj();
    this.getdwList();
  },
  methods: {
    getobj() {
      this.checkedqtdw = [];
      this.checkedzrdw = [];
      const req = {
        handle: 'B37BA078041E48C700BF5F304574952A3A267294DAA2AB9452B87AA1DC447F79',
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        for (let i = 0; i < ts.d.data.operation1.length; i += 1) {
          this.checkedqtdw.push(ts.d.data.operation1[i].hash.orgid);
        }
        for (let i = 0; i < ts.d.data.operation2.length; i += 1) {
          this.checkedzrdw.push(ts.d.data.operation2[i].hash.orgid);
        }
      });
    },
    sumitobj() {
      const req = {
        handle: 'B37BA078041E48C700BF5F304574952A3A267294DAA2AB94BFF0B9210751F692',
        assessorgid: this.checkedqtdw,
        orgid: this.checkedzrdw,
      };
      this.$confirm('确定提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        this.spost(this.ts, '/mainservlet', req).then(() => {
          this.$message({
            type: 'success',
            message: '提交成功!',
          });
          this.getobj();
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消',
        });
      });
    },
    getdwList() {
      const req1 = {
        handle: '67A5B6FEF17D97DECF116BDF95B95C0BC327730680009A98',
        suporgid: '2',
        orgname: '',
      };
      const req2 = {
        handle: '67A5B6FEF17D97DECF116BDF95B95C0BC327730680009A98',
        suporgid: '4',
        orgname: '',
      };
      this.spost(this.ts, '/mainservlet', req1).then((ts) => {
        this.qtdw = ts.d.data.operation1;
      });
      this.spost(this.ts, '/mainservlet', req2).then((ts) => {
        this.zrdw = ts.d.data.operation1;
      });
    },
  },
};
</script>

<style lang="stylus" scoped>
.c_checkbox
  width 92%
  background #ffffff
  margin 20px auto
  padding 20px
  display flex
  justify-content space-around
.chart-container
  min-height 100vh
  background #f1f1f1
  width: 100%;
  float: left;
.w_tip
  width 200px
  line-height 27px
  float left
.el-breadcrumb
  height 60px
  line-height 60px
.select_top
  width 92%
  margin 20px auto
</style>
